﻿using Ninject;

namespace TotalApplication.Core
{
    /// <summary>
    /// The Ioc container for our application
    /// </summary>
    public static class IoC
    {
        #region Public properties
        /// <summary>
        /// The kernel  for our Ioc container
        /// </summary>
        public static IKernel Kernel { get; private set; } = new StandardKernel();

        /// <summary>
        /// UI Manager for messages, dialogs, etc
        /// </summary>
        public static IUManager UI => Get<IUManager>();

        /// <summary>
        /// The logger for the application
        /// </summary>
        public static ILogFactory Logger => Get<ILogFactory>();

        /// <summary>
        /// The total wiew moder for whole application
        /// </summary>
        public static ApplicationViewModel Application => IoC.Get<ApplicationViewModel>();

        /// <summary>
        /// The setting menu view model [Personal Info]
        /// </summary>
        public static SettingMenuViewModel SettingMenu => IoC.Get<SettingMenuViewModel>();

        #region Video Erea


        #endregion

        #endregion

        #region Construction

        /// <summary>
        /// Sets up the Ioc container , binds all information required and is ready for use
        /// NOTE : Must be called as soon as your application starts up to ensure all services can be fund
        /// </summary>
        public static void Setup()
        {
            // BInd all required view models
            BindViewModels();
        }

        /// <summary>
        /// Bind all singleton view models
        /// </summary>
        private static void BindViewModels()
        {
            Kernel.Bind<ApplicationViewModel>().ToConstant(new ApplicationViewModel());

            Kernel.Bind<SettingMenuViewModel>().ToConstant(new SettingMenuViewModel());
        }

        #endregion

        /// <summary>
        /// Get's service from the Ioc
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        public static T Get<T>()
        {
            return Kernel.Get<T>();
        }

    }
}
